//package com.haoran.dwz.service.impl;
//
//import java.util.Map;
////
//import org.springframework.beans.factory.annotation.Autowired;
//import org.springframework.beans.factory.annotation.Value;
//import org.springframework.http.ResponseEntity;
//
//import com.haoran.dwz.common.util.R;
//import com.haoran.dwz.dto.DwzGeneratorDTO;
//import com.haoran.dwz.security.AuthenticationHeader;
//import com.haoran.dwz.service.DwzService;
//import com.ning.http.client.AsyncHttpClient;
//import com.ning.http.client.AsyncHttpClient.BoundRequestBuilder;
//import com.ning.http.client.ListenableFuture;
//import com.ning.http.client.Response;
//
//public class DwzServiceAsyncHttpClientImpl implements DwzService {
//
//	@Value("${dwz.service.address:http://localhost:8080/}")
//	private String SERVICE_ADDRESS;
//
//	@Autowired
//	private AuthenticationHeader authenticationHeader;
//
//	@Autowired
//	private AsyncHttpClient asyncHttpClient;
//
//	@Override
//	public ResponseEntity<R> generate(String url, int type) {
//		try {
//			DwzGeneratorDTO params = new DwzGeneratorDTO(url, type);
//			String content = com.alibaba.fastjson.JSONObject.toJSONString(params);
//			String serviceUrl = SERVICE_ADDRESS + DWZ_GENERATE;
//			Map<String, String> headers = authenticationHeader.create(content);
//			BoundRequestBuilder builder =  asyncHttpClient.preparePost(serviceUrl);
//			for (Map.Entry<String, String> entry : headers.entrySet()) {
//				builder.addHeader(entry.getKey(), entry.getValue());
//			}
//			builder.setBody(content);
//			ListenableFuture<Response> responseFuture =  asyncHttpClient.executeRequest(builder.build());
//			Response response = responseFuture.get();
//			String responseBody = response.getResponseBody();
//			return ResponseEntity.ok(com.alibaba.fastjson.JSONObject.parseObject(responseBody, R.class));
//		} catch (Exception e) {
//			return ResponseEntity.badRequest().build();
//		}
//	}
//
//}
